import json
from collections import Counter

import humps


# https://datatracker.ietf.org/doc/html/rfc2789
# snmptranslate -Td 1.3.6.1.2.1.28.2
def generate_value_frequency():
    values = []
    with open("snmptranslate.txt", "r") as r:
        for line in r.readlines():
            line = line.replace('"', "").strip()
            splits = line.split('\t')
            print(splits[0])
            values.extend(humps.decamelize(splits[0]).split('_'))
    vs = Counter(values).most_common(20000)
    vs = dict(vs)
    for (k, v) in vs.items():
        print(f'{k}: {v}')
        vs[k] = ""
    with open('value_frequency_count.json', 'w') as f:
        json.dump(dict(vs), f, indent=1)


if __name__ == '__main__':
    generate_value_frequency()
